<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <button @click="add">新增obj的a属性</button>
    <button @click="change">修改a属性</button>
    {{ obj.a }}
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
  <script>

    const app = new Vue({
      data: {
        obj: {}
      },
      methods: {
        add() {
          // this.obj.a = '这是a属性';
          this.$set(this.obj, 'a', '这是a属性的值')
        },
        change() {
          this.obj.a = '值修改了';
        }
      },
    })
    app.$mount('#app')
  </script>
</body>

</html>